package prefix.payment;

import java.util.List;

import models.Pay;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import processor.PayProcessor;
import repository.PayRepository;

public class PaymentDueProcessor {

    static Logger logger = LoggerFactory.getLogger("application");

    public static void processPayment() {
        List<Pay> payList = PayRepository.getPaymentDue();
        System.out.println("payment to process : " + payList.size());

        for (Pay pay : payList) {
            try {
                processPayment(pay);
            } catch (Exception e) {
                e.printStackTrace();
            }

        }
    }

    public static void processPayment(Pay pay) {
        try {
            PayProcessor processor = new PayProcessor(pay);
            processor.validateForProcessing();
            processor.processPayment(false);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

}
